#!/bin/bash
set -eEuo pipefail
# the canonical path of this script
SELF_PATH=$(realpath -- "$0")
readonly SELF_PATH SELF_DIR=${SELF_PATH%/*}

# cd to demo project root
cd "$SELF_DIR/.."

readonly BABY_ROOT="$PWD/../scripts/bash-buddy"
source "$BABY_ROOT"/lib/trap_error_info.sh
source "$BABY_ROOT"/lib/common_utils.sh
source "$BABY_ROOT"/lib/java_utils.sh

readonly JDK_VERSIONS=(
  8
  11
  17
  21
  23
)

for jdk_version in "${JDK_VERSIONS[@]}"; do
  jvu::switch_to_jdk "$jdk_version"

  cu::head_line_echo "test demos with Java $jdk_version: $JAVA_HOME"

  cffu-demo/scripts/run.sh
  cffu-kotlin-demo/scripts/run.sh
done
